class GestorPeticion extends Thread {
	BufferedReader entrada = null;
	PrintWriter salida = null;
	Socket s;
	EnviarMensaje em;
	String nick;

	public GestorPeticion(Socket s, EnviarMensaje em){
		this.s = s;
		this.em = em;
		nick = "";
	}


	public void run(){ 
		try{
			entrada = new BufferedReader(new InputStreamReader(s.getInputStream()));
			salida  = new PrintWriter(new BufferedWriter(new OutputStreamWriter(s.getOutputStream())), true);
			salida.println ("Bienvenido a la sala de chat de Ronald");
			salida.println ("Ingresa tu nick: ");
			nick = entrada.readLine ();
      
			while (true){  
				String str = entrada.readLine();
				System.out.println("Recibio: " + str);
				str = nick + "> " + str;
				em.enviarATodos (str, s);
				//salida.println("tu respuesta: "+str);
				if(str.equals("bye")) break;
			}
			
			salida.close();
			entrada.close();
		}
		catch(Exception e){
			e.printStackTrace();
			System.exit(-1);
		}
	}
}
